<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	//显示统计数据
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$new['all']=pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'status'=>0));
	$new['day']=pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'status'=>0,'createtime >'=>$daytime));
	$genjin['all']=pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,4,5,6,7,8)),'id');
	$genjin['day']=pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,4,5,6,7,8),'createtime >'=>$daytime),'id');
	$member['day'] = pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
	$member['all'] = pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid']));
	$isbao['day'] = pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'status >='=>9,'createtime >'=>$daytime));
	$isbao['all'] = pdo_count('jy_yxw_member',array('uniacid'=>$_SESSION['uniacid'],'status >='=>9));
	//月份
	for($i=0;$i<12;$i++){
			if($i==0){
				$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
				$yueend = time();
				
			}else{
				$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'));
				$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'));
			}
			$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5,6));
			$params['createtime between']=array($yuestart,$yueend);
			$month12[] = date('Y-m',strtotime('-'.$i.' month'));
			$monthorder[]=pdo_count('jy_yxw_member',$params);
			$params['status >=']=9;
			$monthfee=pdo_count('jy_yxw_member',$params,'id');
			$monthmoney[]=intval($monthfee);
	}
	$monthorder=array_reverse($monthorder);
	$monthmoney=array_reverse($monthmoney);
	$month12=array_reverse($month12);
	$htmls=array(
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'今日数据/总数据','datas'=>array(
			array('title'=>'待处理客户','num'=>2,'data'=>array($new['day'],$new['all'])),
			array('title'=>'跟进中客户','yuan'=>1,'num'=>2,'data'=>array($genjin['day'],$genjin['all'])),
			array('title'=>'交定金/成交','num'=>2,'data'=>array($isbao['day'],$isbao['all'])),
			array('title'=>'总客户','num'=>2,'data'=>array($member['day'],$member['all'])),
		)),
		array('type'=>'echarts_arealine','ecid'=>'mobile','title'=>'月度成交情况','datas'=>array(
					'datas'=>array(
						array('name'=>'客户数','value'=>$monthorder),
						array('name'=>'成交数','value'=>$monthmoney),
					),
					'xdatas'=>$month12,
		)),
	);
	$return['htmls']=$htmls;
	exi($return);
}